home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Documentation / Books / Learn Java on the Macintosh / Learn Java Projects / 08.03 - is odd / IsOdd.java < prev    next >
Text File  |  1996-04-22  |  652b  |  30 lines

  1. /* -------------------------------------------------------------
  2. This applet illustrates simple flow control.
  3.  
  4. Java's classes: Applet    (applet)
  5.                 System    (lang)
  6.  
  7. Custom classes: IsOdd
  8.  
  9. ------------------------------------------------------------- */
  10. public class IsOdd extends java.applet.Applet {
  11.      public void init() {
  12.     
  13.         int    i;
  14.     
  15.         for ( i = 1; i <= 20; i++ ) {
  16.             System.out.print( "The number " + i + " is ");
  17.         
  18.             if ( (i % 2) == 0 )
  19.                 System.out.print( "even" );
  20.             else
  21.                 System.out.print( "odd" );
  22.         
  23.             if ( (i % 3) == 0 )
  24.                 System.out.print( " and is a multiple of 3" );
  25.                 
  26.             System.out.println("");
  27.      
  28.         }    
  29.     }
  30. }